// |**| Opcon|OperationMango|**|Opcon|OperationMango|**|
// |**| Source Code for the FPS Operation Mango     |**|
// |**| Opcon|OperationMango|**|Opcon|OperationMango|**|
using System;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;

namespace OperationMango
{
	public class Grid : IRenderable
	{
		
		private int m_GridSize;		// Size of our display grid in OpenGL units (has equal sides).
		public int GridSize { get { return m_GridSize; } set { m_GridSize = value; } }
		private int m_GridDetail;	// In (x) grid units, how many lines would we like to display?
		public int GridDetail { get { return m_GridDetail; } set { m_GridDetail = value; } }
		
		
		
		public Grid ()
		{
			GridDetail = 500;
			GridSize = 500;
		}
		
		public Grid(int gridSize, int gridDetail)
		{
			GridSize = gridSize;
			GridDetail = gridDetail;
		}
		
		public void Render(double time)
		{
			RenderGrid();
		}
		
		protected void RenderGrid()
		{
			for (int gs = -GridSize; gs <= GridSize; gs+=(GridSize/GridDetail))
			{
				GL.Begin(BeginMode.Lines);
				GL.Vertex3(-GridSize, 0.0f, (float)gs);
				GL.Vertex3( GridSize, 0.0f, (float)gs);
				GL.End();
			}
			
			for (int gs = -GridSize; gs <= GridSize; gs+=(GridSize/GridDetail))
			{
				GL.Begin(BeginMode.Lines);
				GL.Vertex3((float)gs, 0.0f,-GridSize);
				GL.Vertex3((float)gs, 0.0f, GridSize);
				GL.End();
			}
		}
	}
}

